package com.wing.warehouse.controller;

import com.wing.auth.entity.response.GetTokenResponse;
import com.wing.auth.entity.response.TicketSendResponse;
import com.wing.auth.service.AuthService;
import com.wing.common.exception.BusinessException;
import com.wing.common.utils.JsonResult;
import com.wing.warehouse.entity.request.WarehouseCreateRequest;
import com.wing.warehouse.entity.response.WarehouseQueryResponse;
import com.wing.warehouse.service.WarehouseService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 畅捷通-仓库管理2
 *
 * @author xiayang
 */
@Validated
@Api(value = "畅捷通-仓库管理", tags = "#/chanjet/warehouse")
@RestController("chanjetWarehouseController")
@RequestMapping("warehouse/admin/warehouse")
@RequiredArgsConstructor
public class WarehouseController {

    @Resource
    WarehouseService warehouseService;

    /**
     * 仓库查询
     */
    @PostMapping("/query")
    public JsonResult<List<WarehouseQueryResponse>> query() {
        return JsonResult.success(warehouseService.warehouseQuery());
    }

    /**
     * 仓库创建
     */
    @PostMapping("/create")
    public JsonResult create(WarehouseCreateRequest warehouseCreateRequest) {
        try {
            return warehouseService.warehouseCreate(warehouseCreateRequest);
        } catch (BusinessException e) {
            return JsonResult.fail(e.getMessage());
        }
    }

}
